<?php
namespace app\modules\company\models;
use app\models\Basic;

use Yii;

class CompanyWechat extends Basic
{
    
    public static function tableName()
    {
        return '{{%company_wechat}}';
    }

    public function rules()
    {
        return [
            ['com_id', 'integer', 'message' => 'com_id必须为数字，或数字字符串', 
                        'min'=>0, 'tooSmall' => 'com_id最小存储0', 
                        'max'=>4294967295, 'tooBig' => 'com_id最大存储4294967295'],
            ['appid', 'string', 'message' => 'appid必须是字符串', 
                      'min' => 18, 'tooLong' => 'appid最短18位',
                      'max' => 18, 'tooLong' => 'appid最长18位'],
            ['appsecret', 'string', 'message' => 'appsecret必须是字符串', 
                      'min' => 32, 'tooLong' => 'appsecret最短32位',
                      'max' => 32, 'tooLong' => 'appsecret最长32位'],
            ['isdefault', 'integer', 'message' => 'isdefault必须为数字，或数字字符串'],
            ['isdefault', 'in', 'range' => array(1, 2), 'message' => 'isdefault值必须在1,2中选择'],
            ['add_time', 'default', 'value' => '1000-01-01 00:00:00'],
            ['add_time', 'date', 'format'=>'yyyy-MM-dd HH:mm:ss', 'message' => 'add_time非yyyy-MM-dd HH:mm:ss格式'],
        ];
    }


    /*添加*/
    public function addWechat($data)
    {
        // P($data);
        if($this->load($data) and $this->validate()){
            if($this->save(false)){
                return true;
            }
        }
        return false;
    }

}